<template>
  <div class="car-in-out">
    <div class="top">
      <span style="margin-left: 2.6rem;">车牌</span>
      <span style="margin-left: 8.6rem;">时间</span>
      <span style="margin-left: 10rem;">地址</span>
    </div>
    <div class="scroll-box">
      <div id="scroll1" @mouseover="scrollIf = false" @mouseleave="scrollIf = true,mouseStyleShow = 0">
        <p class="in-car" @mouseover="mouseOver(index)" v-for="(item,index) in carNums" :class="{activeInCar:index%2,'mouse-style': (index + 1000)==mouseStyleShow}">
          <span class="car-num">{{item.carNumber}}</span>
          <span class="in-date">{{item.inTime}}</span>
          <span class="in-parking">{{item.parkName}}</span>
        </p>
      </div>
      <div id="scroll2" @mouseover="scrollIf = false" @mouseleave="scrollIf = true,mouseStyleShow = 0">
        <p class="in-car" @mouseover="mouseOver(index)" v-for="(item,index) in carNums" :class="{activeInCar:index%2,'mouse-style': (index + 1000)==mouseStyleShow}">
          <span class="car-num">{{item.carNumber}}</span>
          <span class="in-date">{{item.inTime}}</span>
          <span class="in-parking">{{item.parkName}}</span>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'car-in-out',
    data() {
      return {
        scrollIf: true,
        mouseStyleShow: 0,
        carNums: []
      }
    },
    mounted() {
      this.getOrderInfo();
    },
    beforeDestroy() {
      if (this.timer) {
        clearInterval(this.timer);
      }
    },
    methods: {
      getOrderInfo() {
        this.$axios({
          method: 'get',
          url: '/park/park-info/idc-order-info',
          params: {parkAddress: '河北省石家庄市'}
        }).then((res) => {
          if(res.code == 200) {
            this.carNums = res.data;
            this.scroll();
          }
        })
      },

      scroll() {
        let self = this;
        let len = 0;
        let lenght;
        let height;
        // height = document.getElementById('scroll1').clientHeight;
        height = 30 * 100;
        this.timer = setInterval(function() {
          if(self.scrollIf) {
            len -= 1;
            lenght = len + "px";
            document.getElementById('scroll1').style.marginTop = lenght;
            if(len == -height) {
              len = 0;
            }
          }
        },60)
      },
      mouseOver(index) {
        this.mouseStyleShow = 1000 + index;
      }
    }
  }
</script>

<style scoped>
  p {
    margin: 0;
  }
  .car-in-out {
    height: 100%;
  }

  .top {
    width: 100%;
    height: 3.4rem;
    background-color: #0F439B;
    display: flex;
    align-items: center;
  }

  .top span {
    color: #02F0FD;
    font-size: 1.4rem;
  }

  .scroll-box {
    /* border: 1px solid red; */
    height: calc(100% - 3.8em);
    overflow: hidden;
    margin-top: 0.6em;
  }
  .in-car {
    font-size: 12px;
    font-family: Adobe Heiti Std R;
    background: rgba(0, 170, 218, 0.1);
    padding: 0 12px;
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
    color: #5E737C ;
    font-family: Adobe Heiti Std R;
    height: 30px;
    line-height: 30px;
  }
  .in-car:hover {
    cursor: pointer;
  }
  .car-num,
  .in-parking {
    color: #1676E9;
    /* font-weight: bold; */

  }
  .in-date {
    padding: 0 4%;
    border-left: 1px solid #1676E9;
    border-right: 1px solid #1676E9;
    margin-left: 4%;
    margin-right: 4%;
    color: #1676E9;
  }
  .activeInCar {
    background-color: transparent;
  }
  .mouse-style {
    /* font-size: 12px;
    font-family: Adobe Heiti Std R;
    background: rgba(0, 170, 218, 0.1);
    padding: 6px 12px;
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
    color: #5E737C ;
    font-family: Adobe Heiti Std R; */
    /* font-size: 14px; */
    background-color: #125d85;
    color: #abd8ee;
    .car-num {
      color: #21B5FF;
    }
  }
  .title-icon {
    height: 0.7em;
    margin-right: -3px;
  }
  .iconOne,
  .iconTwo,
  .iconThree {
    animation: enlarge 0.9s infinite;
  }
  .iconTwo {
    animation-delay: 0.3s;
  }
  .iconThree {
    animation-delay: 0.6s;
  }

  @keyframes enlarge {
    0% {transform: scale(1);}
    33.33% {transform: scale(1.3);}
    66.66% {transform: scale(1);}
    100% {transform: scale(1);}
  }


</style>
